<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Title</title>
    <style>
      * {
        margin: 0;
        padding: 0;
      }

      .container {
        width: 100vw;
        height: 100vh;
        background: url('./bg.png') no-repeat;
        background-size: cover;
      }
      .box {
        width: 1920px;
        height: 1080px;
        background-color: palegoldenrod;
        transform-origin: left top;
        position: fixed;
        top: 50%;
        left: 50%;
      }
      .top {
        width: 100px;
        height: 100px;
        margin-left: 100px;
        background-color: red;
      }
      .bottom {
        margin-left: 100px;
        margin-top: 100px;
        width: 100px;
        height: 100px;
        background-color: skyblue;
      }
    </style>
  </head>
  <body>
    <div class="container">
      <div class="box">
        <div class="top">hello</div>
        <div class="bottom">hello2</div>
      </div>
    </div>
  </body>
  <script>
    //控制数据大屏放大与缩小
    let box = document.querySelector('.box')
    let scale = 1
    box.style.transform = `scale(${getScale()}) translate(-50%,-50%)`

    //计算缩放比例
    function getScale(width = 1920, height = 1080) {
      let scaleX = window.innerWidth / width
      let scaleY = window.innerHeight / height
      return Math.min(scaleX, scaleY)
      //
    }
    window.onresize = () => {
      box.style.transform = `scale(${getScale()}) translate(-50%,-50%)`
    }
  </script>
</html>
